import { getUserInfo } from '@/utils/user';
import React from 'react';
import { Link } from 'umi';

export const renderlinkEle = (id: string, name: string, linkTo: any) => {
  if (!linkTo) return name || id;
  if (typeof linkTo === 'object') {
    return (
      <Link to="" {...linkTo}>
        {name}
      </Link>
    );
  }
  return <Link to={typeof linkTo === 'function' ? linkTo(id) : linkTo}>{name}</Link>;
};

export const getUserLabels = (array: any[], isUserId = true) => {
  return array.map((V) => {
    let user = {};
    if (isUserId) {
      user = getUserInfo(V);
    } else {
      user = getUserInfo('', V);
    }
    return user.userName;
  });
};

// 获取用户数据
export const getUserRecord = (value: string) => {
  return getUserInfo(value);
};
